// 引入 react 依赖
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Text, View, Image, TouchableOpacity, ImageBackground, ScrollView } from 'react-native';

// 引入第三方依赖
import _ from 'lodash';
import pureRender from 'pure-render-decorator';
import { Actions } from 'react-native-router-flux';

// antd 按需加载
import { } from '@ant-design/react-native';

// 引入 处理数据 所需文件
import { } from './module.js'

// 引入样式
import Styles from './style.js';

// 引入公用组件
import { RnImage } from '../../components/index.js'

// 引入工具包
import { press, size, ScreenWidth, ActionsRouter } from '../../util/utils.js'
class Good extends Component {
	static propTypes = {

	}

	constructor(props) {
		super(props)
		this.state = {}
	}

	render() {
		const { data, type } = this.props
		const width = ScreenWidth / 2 - 9
		return (
			<TouchableOpacity
				style={{
					width: width,
					margin: 3,
					marginBottom: 0,
					backgroundColor: '#fff'
				}}
				onPress={() => {
					if (type == 'good') {
						ActionsRouter('goodDetails', { id: data.id })
					}
					if (type == 'magazine') {
						ActionsRouter('magazineDetails', { details: data })
					}
				}}
			>
				<View style={{}}>
					<RnImage resizeMode='cover' style={{ width, height: width }} uri={data.pic} />
				</View>
				<View style={{ padding: 10 }}>
					<Text style={{
						fontSize: 13,
						height: 32,
						color: '#232326',
						lineHeight: 16,
						marginBottom: 5,
					}}>{data.name}</Text>
					<View style={{
						flexDirection: 'row',
						alignItems: 'center',
						justifyContent: 'space-between',
					}}>
						<Text style={{
							fontSize: 13,
							color: '#f23030',
							lineHeight: 16,
						}}>RM{data.price}</Text>
						<Text style={{
							fontSize: 11,
							color: '#bfbfbf',
							lineHeight: 16,
							textDecorationLine: "line-through",
						}}>RM{data.originalPrice}</Text>
						<Text style={{
							fontSize: 11,
							color: '#686868',
							lineHeight: 16,
						}}>已售{data.sale}</Text>
					</View>
				</View>
			</TouchableOpacity>
		)
	}
}

export default pureRender(Good)
